/**
 * @作者：xie
 * @时间：2022/10/8 13:47
 */

//简单工厂SimpleFactory
public class Factory{
    public static void main(String[] args) {
        Product productA=Factory1.createProduct("A");
        productA.info();

        Product productB=Factory1.createProduct("B");
        productB.info();
    }
}

class Factory1{
    /**
     * @param type
     * @return
     */
    public static Product createProduct(String type){
        Product product = null;
        switch(type){
            case "A":
                product=new ProductA();
                break;
            case "B":
                product=new ProductB();
                break;
            default:
                System.out.println("my");
                break;
        }
        return product;
    }
}

abstract class Product{
    public abstract void info();
}

class ProductA extends Product {
    @Override
    public void info(){
        System.out.println("产品信息：A");
    }
}
class ProductB extends Product {
    @Override
    public void info(){
        System.out.println("产品信息：B");
    }
}